<template>
	<view class="user-view">
		<view class="top-bar"><uni-navbar :fixed="true" :back="false" color="#fff" title="我的"></uni-navbar></view>

		<view class="info-box">
			<view class="sub-box" @click="login">
				<image class="sub-img" :src="$imagePreview(userInfo.imagePath)" mode="aspectFill"></image>
				<view class="sub-info">
					<view class="clamp">{{ userInfo.username ? userInfo.username : '无昵称' }}</view>
					<view class="sub-node">
						<text class="txt">{{ userInfo.roleNames ? userInfo.roleNames[0] : '人民群众' }}</text>
					</view>
				</view>
			</view>
		</view>

		<u-cell-group class="link-list">
			<u-cell-item title="基本信息" v-if="userInfo.sysUser" @click="navTo('/pages/user/info?style=self')">
				<template v-slot:icon>
					<image class="list-icon" src="/static/img/icon_01.png" mode="widthFix"></image>
				</template>
			</u-cell-item>
			<!-- <u-cell-item title="履职信息" v-if="$sysMenus('perform')" @click="perform()">
				<template v-slot:icon>
					<image class="list-icon" src="/static/img/icon_02.png" mode="widthFix"></image>
				</template>
			</u-cell-item> -->
			<!-- <u-cell-item title="使用手册" @click="navTo('/pages/user/manual')">
				<template v-slot:icon>
					<image class="list-icon" src="/static/img/icon_04.png" mode="widthFix"></image>
				</template>
			</u-cell-item> -->
			<!-- <u-cell-item title="热线电话" @click="navTo('/pages/user/phone')" :borderBottom="false">
				<template v-slot:icon>
					<image class="list-icon" src="/static/img/icon_07.png" mode="widthFix"></image>
				</template>
			</u-cell-item> -->
		</u-cell-group>

		<view class="form-btn" @click="loginOut">切换登录</view>
	</view>
</template>

<script>
import { mapState } from 'vuex';
export default {
	data() {
		return {
			statistics: false
		};
	},
	onLoad() {
		this.loadLogin();
	},
	computed: {
		...mapState(['userInfo'])
	},
	methods: {
		loadLogin() {
			if (this.userInfo.sysUser) {
				this.region = this.userInfo.sysUser.remark2;
				if (this.region?.length < 12) {
					this.statistics = true;
				}
			}
		},
		login() {
			if (!this.userInfo.sysUser) {
				this.loginOut();
			}
		},
		loginOut() {
			this.$store.commit('logout');
			uni.navigateTo({
				url: '/pages/login/login'
			});
		},
		perform() {
			if (this.$sysMenus('perform_eval_group')) {
				uni.navigateTo({
					url: '/pagesA/duties/index'
				});
			} else {
				//判断是否代表团
				if (this.$roleCodes('xiaozuguanliyuan')) {
					let wyhdz = this.userInfo.userInfo.wyhdz;
					if (wyhdz == null || wyhdz == '') {
						wyhdz = this.userInfo.userInfo.remark4;
					}
					uni.navigateTo({
						url: '/pagesA/duties/group?wyhdz=' + wyhdz
					});
				} else {
					uni.navigateTo({
						url: '/pagesA/duties/self'
					});
				}
			}
		},
		navTo(url) {
			uni.navigateTo({
				url: url
			});
		}
	}
};
</script>

<style lang="scss">
.info-box {
	margin-bottom: 0;
}

.form-btn {
	margin-bottom: 20rpx;
	font-size: 16px;
	color: #101010;
	text-align: center;
	line-height: 100rpx;
	background-color: #fff;
}

.link-list {
	display: block;
	margin-bottom: 20rpx;
	overflow: hidden;
	background-color: #fff;

	.list-item {
		font-size: 28rpx;
		line-height: 72rpx;
	}

	.list-icon {
		width: 15px;
		margin-right: 16rpx;
	}
}
</style>
